package com.unei.guava.demo.fp.supplier;

import com.google.common.base.*;
import com.google.common.collect.Maps;
import com.unei.guava.demo.fp.City;
import com.unei.guava.demo.fp.State;

import java.util.Map;

/**
 * Created by sunlei on 2015/1/21.
 */
class ComposedPredicateSupplier implements Supplier<Predicate<String>> {
    @Override
    public Predicate<String> get() {
        City city=new City("Austin,TX");
        State state=new State("Texas");
        state.setCode("TX");
        City city1=new City("New York,NY");
        State state1=new State("New York");
        state1.setCode("NY");
        Map<String,State> stateMap= Maps.newHashMap();
        stateMap.put(state.getCode(),state);
        stateMap.put(state1.getCode(),state1);
        Function<String,State> mf= Functions.forMap(stateMap);

        return Predicates.compose(new RegionPredicate(), mf);
    }
}
